package testpackage;

import java.util.Calendar;
import java.util.Collection;
import java.util.GregorianCalendar;
import java.util.Iterator;

import org.apache.log4j.Logger;

import orm.Items;
import orm.Roles;
import orm.Transactions;
import orm.Users;

import hibernatelogic.HibItems;
import hibernatelogic.HibRoles;
import hibernatelogic.HibTransactions;
import hibernatelogic.HibUsers;

public class testclass {

	private static final Logger loggerForTestClass = Logger.getLogger(testclass.class); 
	
	public static void main(String[] args) {
		
		Collection col = null;
		Iterator it = null;
		GregorianCalendar gc = new GregorianCalendar(2008, 8, 8);
		
		try {
			
//========================== ROLES TEST BLOCK ============================\\			
//			HibRoles hibRoles = new HibRoles();
//			col = hibRoles.getAllRoles();
//			it = hibRoles.getAllRoles().iterator();
//			while (it.hasNext()) {
//				Roles roles = (Roles) it.next();
//				System.out.println("ID: " + roles.getRole_id() + " Role: "
//						+ roles.getRole_name());
//			}
//========================================================================\\

//======================= USERS TEST BLOCK ===============================\\
//			HibUsers hibUsers = new HibUsers();
//			col = hibUsers.getAllUsers();
//			it = hibUsers.getAllUsers().iterator();
//			while (it.hasNext()) {
//				Users users = (Users) it.next();
//				System.out.println("ID: " + users.getUser_id() + " Name: "
//						+ users.getName() + " Login: " + users.getLogin()
//						+ " Password: " + users.getPassword() + " Role: "
//						+ users.getRole());
//			}
//			Users user = new Users();
//			user.setName("Petrov I.");
//			user.setLogin("login1");
//			user.setPassword("password1");
//			user.setRole(3);
//			hibUsers.addUser(user);
//			user = hibUsers.getUserByID(5);
//			System.out.println(user.getUser_id() + " " + user.getName() + " " + user.getLogin() + " " + user.getPassword() + " " + user.getRole());
//			hibUsers.deleteUser(user);
//=========================================================================\\

//======================= ITEM TEST BLOCK =================================\\
//			HibItems hibItems = new HibItems();
//			col = hibItems.getAllItems();
//			it = hibItems.getAllItems().iterator();
//			while (it.hasNext()) {
//				Items items = (Items) it.next();
//				System.out.println("ID: " + items.getItem_id() + " Name: "
//						+ items.getItem_name() + " Price: "
//						+ items.getItem_price());
//			}
//			Items item = new Items();
//			item.setItem_name("some_item");
//			item.setItem_price(23);
//			hibItems.addItem(item);
//			item = hibItems.getItemByID(6);
//			System.out.println(item.getItem_id() + " " + item.getItem_name() + " " + item.getItem_price());
//			hibItems.deleteItem(item);
//========================================================================\\

//====================== TRANSACTIONS TEST BLOCK =========================\\
//			HibTransactions hibTransactions = new HibTransactions();
//			col = hibTransactions.getAllTransactions();
//			it = hibTransactions.getAllTransactions().iterator();
//			while (it.hasNext()) {
//				Transactions transactions = (Transactions) it.next();
//				System.out
//						.println("ID: "
//								+ transactions.getTr_id()
//								+ " User: "
//								+ transactions.getUsers()
//								+ " Item: "
//								+ transactions.getItems()
//								+ " Quantity: "
//								+ transactions.getQuantity()
//								+ " Date: "
//								+ transactions.getSal_time().get(Calendar.YEAR)
//								+ "-"
//								+ (transactions.getSal_time().get(
//										Calendar.MONTH) + 1)
//								+ "-"
//								+ transactions.getSal_time().get(
//										Calendar.DAY_OF_MONTH) 
//								+ " Status: " 
//								+ transactions.getStatus());
//			}
//			
//			Transactions trans = new Transactions();
//			trans.setUsers(1);
//			trans.setItems(1);
//			trans.setQuantity(5);
//			trans.setSal_time(gc);
//			trans.setStatus("N");
//			hibTransactions.addTransaction(trans);
//			trans = hibTransactions.getTransactionByID(7);
//			trans.setStatus("A");
//			hibTransactions.updateTransaction(trans);
//			col = hibTransactions.getNotApprovedTransactions();
//			it = hibTransactions.getNotApprovedTransactions().iterator();
//			while (it.hasNext()) {
//				Transactions transactions = (Transactions) it.next();
//				System.out
//						.println("ID: "
//								+ transactions.getTr_id()
//								+ " User: "
//								+ transactions.getUsers()
//								+ " Item: "
//								+ transactions.getItems()
//								+ " Quantity: "
//								+ transactions.getQuantity()
//								+ " Date: "
//								+ transactions.getSal_time().get(Calendar.YEAR)
//								+ "-"
//								+ (transactions.getSal_time().get(
//										Calendar.MONTH) + 1)
//								+ "-"
//								+ transactions.getSal_time().get(
//										Calendar.DAY_OF_MONTH) 
//								+ " Status: " 
//								+ transactions.getStatus());
//			}
//=====================================================================================
			
		} catch (Exception e) {
			loggerForTestClass.error("Something wrong", e);
		}
	}
}
